package com.guhecloud.step.definition.runtime.def;

import com.guhecloud.step.definition.runtime.IDomainStep;
import com.guhecloud.step.definition.runtime.IRegistryAware;
import com.guhecloud.step.definition.runtime.InternalIndexer;
import com.guhecloud.step.definition.runtime.annotation.Step;
import com.guhecloud.step.definition.runtime.tool.InternalAopUtils;
import lombok.Getter;

public class StepDef implements IRegistryAware {
    @Getter
    private String activity;

    @Getter
    private String code;

    @Getter
    private String name;

    @Getter
    private String[] tags;

    @Getter
    private IDomainStep stepBean;

    @Override
    public void registerBean(Object bean) {
        Step domainStep = InternalAopUtils.getAnnotation(bean, Step.class);
        this.name = domainStep.name();
        this.tags = domainStep.tags();
        this.stepBean = (IDomainStep) bean;
        this.activity = this.stepBean.activityCode();
        this.code = this.stepBean.stepCode();
        InternalIndexer.index(this);
    }
}
